using UnityEngine;

public class DrawDebug
{
    [SerializeField] private bool drawDebug = false;

    public static void Line(Vector3 start, Vector3 end, Color color = new Color(), LayerMask layer = new LayerMask())
    {
        var direction = end - start;
        var ray = new Ray(start, direction.normalized);
        if (Physics.Raycast(ray, out var hit, direction.magnitude, layer))
        {
            Gizmos.color = color;
            Gizmos.DrawLine(start, hit.point);
            Gizmos.color = Color.green;
            Gizmos.DrawSphere(hit.point, 0.02f);
            Gizmos.DrawLine(hit.point, end);
        }
        else
        {
            Gizmos.color = color;
            Gizmos.DrawLine(start, end);
        }
    }

}
